﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Vit.Mvc.Results
{
    public class PartialErrorResult : PartialViewResult
    {
        private string message;

        public PartialErrorResult()
        {
        }

        public PartialErrorResult(string message)
        {
            this.message = message;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            ViewName = "Error";

            ViewData = context.Controller.ViewData;
            TempData = context.Controller.TempData;

            ViewData.Add("message", message);

            base.ExecuteResult(context);

            context.HttpContext.Response.StatusDescription = "Internal Error";
            context.HttpContext.Response.StatusCode = 500;
        }
    }
}
